#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>

int main(){
  pid_t id = fork();
  if(id < 0){
    perror("fork");
    return 1;
  }
  else if(id == 0){
    while(1){
      printf("子进程，pid为%d, ppid为%d\n",getpid(), getppid());
      sleep(1);
    }
  }
  else{
    printf("父进程，pid为%d\n", getpid());
    sleep(5);
  }
  return 0;
}
